interface urlType{
    id:string,
    title:string
}

interface ItemType{
    img:string,
    id:string,
    title:string,
    desc:string,
    text:string
}

interface DataType{
    code:number,
    data:ItemType
}

function urlObj(url:string){
    const urlArr=url.split('?')[1].split('&')
    let obj:urlType|{}={}
    urlArr.forEach(item=>{
        const keys=item.split('=')[0]

        obj={
            ...obj,
            [keys]:item.split('=')[1]
        }
    })
    return obj as urlType
}

const urlValue:urlType=urlObj(location.href);
console.log(urlValue)
Ajax(`/api/getDetail?id=${urlValue.id}`,(data:DataType)=>{
    
    render(data.data)
})

function render(data:ItemType){
    const detailWrap=document.querySelector('.detailWrap');
    (detailWrap as Element).innerHTML=`
    <div>
        <h1>${data.title}</h1>
        <img src='${data.img}' alt>
        <p>${data.desc}</p>
        <p>${data.text}</p>    
    </div>
    `
}